/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package model.impl;

import model.ModelPackage;
import model.Role;

import model.SerieRole;
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Role</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link model.impl.RoleImpl#getSerie <em>Serie</em>}</li>
 *   <li>{@link model.impl.RoleImpl#getSerieRole <em>Serie Role</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RoleImpl extends EntityProfileImpl implements Role {
	/**
	 * The default value of the '{@link #getSerie() <em>Serie</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSerie()
	 * @generated
	 * @ordered
	 */
	protected static final String SERIE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getSerie() <em>Serie</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSerie()
	 * @generated
	 * @ordered
	 */
	protected String serie = SERIE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getSerieRole() <em>Serie Role</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSerieRole()
	 * @generated
	 * @ordered
	 */
	protected SerieRole serieRole;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RoleImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ModelPackage.Literals.ROLE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getSerie() {
		return serie;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSerie(String newSerie) {
		String oldSerie = serie;
		serie = newSerie;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.ROLE__SERIE, oldSerie, serie));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SerieRole getSerieRole() {
		if (serieRole != null && serieRole.eIsProxy()) {
			InternalEObject oldSerieRole = (InternalEObject)serieRole;
			serieRole = (SerieRole)eResolveProxy(oldSerieRole);
			if (serieRole != oldSerieRole) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ModelPackage.ROLE__SERIE_ROLE, oldSerieRole, serieRole));
			}
		}
		return serieRole;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SerieRole basicGetSerieRole() {
		return serieRole;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetSerieRole(SerieRole newSerieRole, NotificationChain msgs) {
		SerieRole oldSerieRole = serieRole;
		serieRole = newSerieRole;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.ROLE__SERIE_ROLE, oldSerieRole, newSerieRole);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSerieRole(SerieRole newSerieRole) {
		if (newSerieRole != serieRole) {
			NotificationChain msgs = null;
			if (serieRole != null)
				msgs = ((InternalEObject)serieRole).eInverseRemove(this, ModelPackage.SERIE_ROLE__ROLE, SerieRole.class, msgs);
			if (newSerieRole != null)
				msgs = ((InternalEObject)newSerieRole).eInverseAdd(this, ModelPackage.SERIE_ROLE__ROLE, SerieRole.class, msgs);
			msgs = basicSetSerieRole(newSerieRole, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.ROLE__SERIE_ROLE, newSerieRole, newSerieRole));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.ROLE__SERIE_ROLE:
				if (serieRole != null)
					msgs = ((InternalEObject)serieRole).eInverseRemove(this, ModelPackage.SERIE_ROLE__ROLE, SerieRole.class, msgs);
				return basicSetSerieRole((SerieRole)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.ROLE__SERIE_ROLE:
				return basicSetSerieRole(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ModelPackage.ROLE__SERIE:
				return getSerie();
			case ModelPackage.ROLE__SERIE_ROLE:
				if (resolve) return getSerieRole();
				return basicGetSerieRole();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ModelPackage.ROLE__SERIE:
				setSerie((String)newValue);
				return;
			case ModelPackage.ROLE__SERIE_ROLE:
				setSerieRole((SerieRole)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ModelPackage.ROLE__SERIE:
				setSerie(SERIE_EDEFAULT);
				return;
			case ModelPackage.ROLE__SERIE_ROLE:
				setSerieRole((SerieRole)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ModelPackage.ROLE__SERIE:
				return SERIE_EDEFAULT == null ? serie != null : !SERIE_EDEFAULT.equals(serie);
			case ModelPackage.ROLE__SERIE_ROLE:
				return serieRole != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (serie: ");
		result.append(serie);
		result.append(')');
		return result.toString();
	}

} //RoleImpl
